/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package projetointegrado;

import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;

/**
 *
 * @author Emerson
 */
public class DesenhaTela extends Thread {

    JanelaJogo jj;
    Canvas canvas;
    Player player;
    final int WIDTH;
    final int HEIGHT;
    private BufferedImage char_male;
    private BufferedImage lifebar;
    private BufferedImage manabar;
    private BufferedImage imagebg;
    private BufferedImage corrimao_direita;
    private BufferedImage corrimao_esquerda;
    private BufferedImage tia_limpeza;
    private BufferedImage sala_blocoB;
    private BufferedImage sala2_blocoB;
    private BufferedImage chao_blocoB;
    private BufferedImage bolaDeFogo;
    private int xTia1 = 150;
    private int yTia1 = 450;
    private boolean praCima = true;
    private boolean praBaixo = false;
    KeyboardInput keyboard;
    Movement m;
    String bloco;
    ArrayList<Rectangle> arrayRetangulos;
    public static Graphics2D g2d = null;
    Enemy inimigo = ProjetoIntegrado.inimigo;

    public static void playerFalou(String s) {
        g2d.drawString(s, ProjetoIntegrado.player.getPosX(), ProjetoIntegrado.player.getPosY() - 15);
    }

    public DesenhaTela(JanelaJogo jj, Canvas canvas, Player player, int WIDTH, int HEIGHT, BufferedImage char_male, KeyboardInput keyboard, Movement m, String bloco) {
        this.jj = jj;
        this.bloco = jj.getBloco();
        this.canvas = canvas;
        this.player = player;
        this.WIDTH = WIDTH;
        this.HEIGHT = HEIGHT;
        this.char_male = char_male;
        this.keyboard = keyboard;
        this.m = m;
        Flag.blocoAtual = bloco;
        inimigo.setBaseAttack(10);
        inimigo.setHp(100);
        inimigo.setModificadorDificuldade(1);
        inimigo.setSkillAdm(8);
        inimigo.setSkillHum(8);
        inimigo.setSkillMat(8);
        inimigo.setSkillProg(8);



    }
//    public void setJogador(int x, int y, int w,int h){
//        jogador.setBounds(x, y, w, h);
//    }
//    public Rectangle getJogador(){
//        return jogador;
//    }

    @Override
    public synchronized void run() {


        System.out.println("THE THREAD LIIIIIIIIIIVES!");
        canvas.createBufferStrategy(1);
        BufferStrategy buffer = canvas.getBufferStrategy();
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = ge.getDefaultScreenDevice();
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        BufferedImage bi = gc.createCompatibleImage(WIDTH, HEIGHT);
        Graphics graphics = null;
        char_male = null;
        lifebar = null;
        manabar = null;
        Color background = Color.BLACK;
        ProjetoIntegrado.pld.PainelLateralDireito(player);
        Flag.playSoundOnce = true;
        while (true) {
            if (Flag.colisao == false) {
                System.out.println("entrou no loooooop");
                if (Flag.batalha) {
                    System.out.println("batalha");
                    Flag.batalha = false;
                    PainelBatalha pb = new PainelBatalha(player, inimigo, this);
                    jj.setVisible(false);
                    pb.setBounds(0, 0, 830, 600);
                    ProjetoIntegrado.janelaPrincipal.add(pb);
                    pb.setVisible(true);
                    pb.requestFocus();
                }
                if (Flag.morreu == true) {
                    System.out.println("morte coitado");
                    Flag.morreu = false;
                    ProjetoIntegrado.pgo.setVisible(false);
                    jj.setVisible(false);
                    Flag.desenhatela = null;
                    this.suspend();

                }
                if (Flag.passouPro2Periodo) {
                    System.out.println("passou segundo periodod");
                    player.periodo = 2;
                }
//          for(int i = 0;i < 7 ;i++){
//              if(player.materias.get(i).getStatus() != 3){
//                  Flag.passouPro2Periodo = false;
//              }else{
//                  Flag.passouPro2Periodo = true;
//              }
//              
//          }



                if (Flag.utaniAtivado) {
                    System.out.println("problem utani");
                    Flag.contadorDeClock++;
                }
                if (Flag.contadorDeClock == 100) {
                    System.out.println("contador de clock");
                    Flag.utaniAtivado = false;
                    Flag.contadorDeClock = 0;
                    player.dx = player.dx - player.aumentoVeloUtani;
                    player.dy = player.dy - player.aumentoVeloUtani;
                }
                if (Flag.primeiraVez) {
                    System.out.println("primeira vez first");
                    player.setHp(player.getHp());
                    player.setMana(player.getMana());
                    player.setHpAtual(player.getHpAtual() + 1);
                    player.setManaAtual(player.getManaAtual() + 1);
                    Flag.primeiraVez = false;
                }
                ProjetoIntegrado.pld.setVida(player.getHpAtual());
                Flag.numero = ProjetoIntegrado.pld.calculaTamanhoBarra(player);
                ProjetoIntegrado.pld.setBarraVida(Flag.numero);
                ProjetoIntegrado.pld.setMana(player.getManaAtual());
                Flag.numero = ProjetoIntegrado.pld.calculaTamanhoBarraMana(player);
                ProjetoIntegrado.pld.setBarraMana(Flag.numero);



                if (Flag.irParaMapa) {
                    jj.setVisible(false);
                    System.out.println("mapa");
                }
                if (Flag.irParaMatriz) {
                    jj.setVisible(false);
                    System.out.println("matriz");
                }
                if (Flag.irParaEnsalamento) {
                    jj.setVisible(false);
                    System.out.println("ensalamento");
                }
                if (Flag.saindoDaMatriz) {
                    jj.setVisible(true);
                    Flag.saindoDaMatriz = false;
                    System.out.println("saiu da matriz");
                }
                if (Flag.saindoEnsalamento) {
                    jj.setVisible(true);
                    Flag.saindoEnsalamento = false;
                    System.out.println("saiu ensalamento");
                }



                try {
                    keyboard.poll();
                    System.out.println("PASSOU PELO KEYBOARD");
                    if (keyboard.keyDownOnce(KeyEvent.VK_ESCAPE)) {
                        System.out.println("VERIFICOU ESCAPE");
                        System.out.println("ESCAPE");
                        //   jj.setVisible(false);
                        JanPrincipal.opcoes.requestFocus();
                        JanPrincipal.opcoes.setVisible(true);

                        System.out.println("opcoes visivel");

                    }

                    final Rectangle jogador = new Rectangle(player.getPosX(), player.getPosY(), player.w, player.h);

                    g2d = bi.createGraphics();
                    // g2d.setColor( background );


                    // g2d.fillRect( 0, 0, WIDTH, HEIGHT );




                    if (bloco.equals("Bloco E")) {
                        System.out.println("bloco e");
                        arrayRetangulos = desenhaBlocoE();
                        if (Flag.playSoundOnce) {
                            ProjetoIntegrado.sound.playBlocoB();
                        }
                        Flag.playSoundOnce = false;
                    }
                    if (bloco.equals("Bloco B")) {
                        System.out.println("bloco b");
                        arrayRetangulos = desenhaBlocoB();
                        if (Flag.playSoundOnce) {
                            ProjetoIntegrado.sound.playBlocoB();
                        }
                        Flag.playSoundOnce = false;
                    }
                    if (Flag.andar1BlocoE) {
                        System.out.println("andar 1 bloco e");
                        //   player.setPosX(700);
                        //   player.setPosY(350);
                        arrayRetangulos = desenha1AndarBlocoE();
                    }
                    if (Flag.andar2BlocoE) {
                        System.out.println("andar 2 bloco e");
                        arrayRetangulos = desenha2AndarBlocoE();
                    }
                    if (Flag.andar3BlocoE) {
                        System.out.println("andar 3 bloco e");
                        arrayRetangulos = desenha3AndarBlocoE();
                    }

                    //Flag.andar1BlocoE = false;

//        Rectangle muro = new Rectangle(0, 200, 500, 50);
//        Rectangle inimigo = new Rectangle(0, 300, 600, 70);
//     public void bolaDeFogoCentro(){
//                    g2d.drawImage(bolaDeFogo, player.getPosX()-30, player.getPosY()-30,jj);
//                    g2d.drawImage(bolaDeFogo, player.getPosX(), player.getPosY()-30,jj);
//                    g2d.drawImage(bolaDeFogo, player.getPosX()+30, player.getPosY()-30,jj);
//                    g2d.drawImage(bolaDeFogo, player.getPosX()-30, player.getPosY(),jj);
//                    g2d.drawImage(bolaDeFogo, player.getPosX(), player.getPosY(),jj);
//                    g2d.drawImage(bolaDeFogo, player.getPosX()+30, player.getPosY(),jj);
//                    g2d.drawImage(bolaDeFogo, player.getPosX()-30, player.getPosY()+30,jj);
//                    g2d.drawImage(bolaDeFogo, player.getPosX(), player.getPosY()+30,jj);
//                    g2d.drawImage(bolaDeFogo, player.getPosX()+30, player.getPosY()+30,jj);
//     }   



                    if (Flag.bolaDeFogo) {
                        System.out.println("ENTROU NO BOLA DE FOGO");

                        Flag.contadorBolaDeFogo++;

                        if (player.getPosChar().equals("src/Imagens/char_tibia_down2.png") || player.getPosChar().equals("src/Imagens/char_tibia_down3.png") || player.getPosChar().equals("src/Imagens/char_tibia_down1.png")) {
                            bolaDeFogoBaixo();
                        } else if (player.getPosChar().equals("src/Imagens/char_tibia_up2.png") || player.getPosChar().equals("src/Imagens/char_tibia_up3.png") || player.getPosChar().equals("src/Imagens/char_tibia_up1.png")) {
                            bolaDeFogoCima();
                        } else if (player.getPosChar().equals("src/Imagens/char_tibia_left2.png") || player.getPosChar().equals("src/Imagens/char_tibia_left3.png") || player.getPosChar().equals("src/Imagens/char_tibia_left1.png")) {
                            bolaDeFogoLeft();
                        } else if (player.getPosChar().equals("src/Imagens/char_tibia_right2.png") || player.getPosChar().equals("src/Imagens/char_tibia_right3.png") || player.getPosChar().equals("src/Imagens/char_tibia_right1.png")) {
                            bolaDeFogoRight();
                        }

                    }
                    if (Flag.contadorBolaDeFogo >= 10) {
                        Flag.bolaDeFogo = false;
                        Flag.contadorBolaDeFogo = 0;
                    }

                    //g2d.drawString("X ="+ String.valueOf(player.getPosX())+ ": Y = " + String.valueOf(player.getPosY()),50,50);
                    System.out.println("mandou pro movimenta");
                    m.Movimenta(jogador, arrayRetangulos);
                    
                   

                    //  System.out.println(i);
                    //g2d.drawRect(player.getPosX(),player.getPosY(),player.w,player.h);

                    if (Flag.colisao == false) {

                        try {
                            sleep(30);
                        } catch (InterruptedException ex) {
                            Logger.getLogger(DesenhaTela.class.getName()).log(Level.SEVERE, null, ex);
                        }

                        try {
                            lifebar = ImageIO.read(
                                    new File(m.getPlayer().lifebar));
                            manabar = ImageIO.read(
                                    new File(m.getPlayer().manabar));
                            char_male = ImageIO.read(
                                    new File(m.getPlayer().getPosChar()));

                        } catch (IOException exc) {
                        }

                        try {
                            bolaDeFogo = ImageIO.read(
                                    new File("src/Imagens/bola_de_fogo.png"));
                        } catch (IOException ex) {
                            Logger.getLogger(DesenhaTela.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        g2d.drawImage(manabar, player.getPosX(), player.getPosY() - 4, jj);
                        g2d.drawImage(lifebar, player.getPosX(), player.getPosY() - 10, jj);
                        g2d.drawImage(char_male, player.getPosX(), player.getPosY(), jj);



                        graphics = buffer.getDrawGraphics();
                        graphics.drawImage(bi, 0, 0, null);

                        if (!buffer.contentsLost()) {
                            buffer.show();

                        }

                        try {

                            Thread.sleep(30);

                        } catch (Exception e) {
                            System.out.println("ERRO!!");
                        }


                        if (player.getPosChar().equals("src/Imagens/char_tibia_down2.png") || player.getPosChar().equals("src/Imagens/char_tibia_down3.png")) {
                            player.setPosChar("src/Imagens/char_tibia_down1.png");
                        } else if (player.getPosChar().equals("src/Imagens/char_tibia_up2.png") || player.getPosChar().equals("src/Imagens/char_tibia_up3.png")) {
                            player.setPosChar("src/Imagens/char_tibia_up1.png");
                        } else if (player.getPosChar().equals("src/Imagens/char_tibia_left2.png") || player.getPosChar().equals("src/Imagens/char_tibia_left3.png")) {
                            player.setPosChar("src/Imagens/char_tibia_left1.png");
                        } else if (player.getPosChar().equals("src/Imagens/char_tibia_right2.png") || player.getPosChar().equals("src/Imagens/char_tibia_right3.png")) {
                            player.setPosChar("src/Imagens/char_tibia_right1.png");
                        }
                    }
                    try {
                        lifebar = ImageIO.read(
                                new File(m.getPlayer().lifebar));
                        manabar = ImageIO.read(
                                new File(m.getPlayer().manabar));
                        char_male = ImageIO.read(
                                new File(m.getPlayer().getPosChar()));
                    } catch (IOException exc) {
                    }
                    g2d.drawImage(manabar, player.getPosX(), player.getPosY() - 4, jj);
                    g2d.drawImage(lifebar, player.getPosX(), player.getPosY() - 10, jj);
                    g2d.drawImage(char_male, player.getPosX(), player.getPosY(), jj);
                    graphics = buffer.getDrawGraphics();
                    graphics.drawImage(bi, 0, 0, null);

                    if (player.getHpAtual() <= 0) {
                        ProjetoIntegrado.pgo.setVisible(true);
                        //player.setPosX(500);
                        //player.setPosY(500); 

                        // Flag.pararThread = true;
                        //this.suspend();

                    }



                    if (Flag.pararThread == true) {
                        Flag.pararThread = false;
                        this.suspend();
                    }


                } finally {
                    if (graphics != null) {
                        graphics.dispose();
                    }
                    if (g2d != null) {
                        g2d.dispose();
                    }
                }
            }
        }
    }

    public ArrayList<Rectangle> desenha1AndarBlocoE() {

        try {
            imagebg = ImageIO.read(
                    new File("src/Imagens/bg_blocoE.jpg"));
        } catch (IOException e) {
        }
        int altura, largura;
        for (largura = 0; largura <= WIDTH; largura = largura + 20) {
            for (altura = 0; altura <= HEIGHT; altura = altura + 20) {
                g2d.drawImage(imagebg, largura, altura, jj);
            }
        }
        g2d.setColor(Color.red);
        g2d.drawString("E-101", 25, 265);
        g2d.drawString("E-102", 330, 265);
        g2d.drawString("E-103", 630, 265);
        Rectangle p1 = new Rectangle(0, 0, 830, 250);
        g2d.fillRect(0, 0, 830, 150);
        Rectangle p2 = new Rectangle(0, 550, 830, 250);
        g2d.fillRect(0, 450, 830, 150);
        Rectangle p3 = new Rectangle(28, 250, 35, 2);
        g2d.fillRect(28, 250, 35, 2);
        Rectangle p4 = new Rectangle(330, 250, 35, 2);
        g2d.fillRect(330, 250, 35, 2);
        Rectangle p5 = new Rectangle(630, 250, 35, 2);
        g2d.fillRect(630, 250, 35, 2);

        try {
            sala_blocoB = ImageIO.read(
                    new File("src/Imagens/sala_blocoB.png"));
            sala2_blocoB = ImageIO.read(
                    new File("src/Imagens/sala2_blocoB.png"));
        } catch (IOException exc) {
        }
        g2d.drawImage(sala_blocoB, 0, 0, jj);
        g2d.drawImage(sala_blocoB, 300, 0, jj);
        g2d.drawImage(sala_blocoB, 600, 0, jj);
        g2d.drawImage(sala2_blocoB, 0, 400, jj);
        g2d.drawImage(sala2_blocoB, 300, 400, jj);
        g2d.drawImage(sala2_blocoB, 600, 400, jj);

        ArrayList<Rectangle> retangulos = new ArrayList<Rectangle>();
        retangulos.add(p1);
        retangulos.add(p2);
        retangulos.add(p3);
        retangulos.add(p4);
        retangulos.add(p5);
        return retangulos;
    }

    public ArrayList<Rectangle> desenha2AndarBlocoE() {
        try {
            imagebg = ImageIO.read(
                    new File("src/Imagens/bg_blocoE.jpg"));
        } catch (IOException e) {
        }
        int altura, largura;
        for (largura = 0; largura <= WIDTH; largura = largura + 20) {
            for (altura = 0; altura <= HEIGHT; altura = altura + 20) {
                g2d.drawImage(imagebg, largura, altura, jj);
            }
        }
        g2d.setColor(Color.red);
        g2d.drawString("E-201", 25, 265);
        g2d.drawString("E-202", 330, 265);
        g2d.drawString("E-203", 630, 265);
        Rectangle p1 = new Rectangle(0, 0, 830, 250);
        g2d.fillRect(0, 0, 830, 150);
        Rectangle p2 = new Rectangle(0, 550, 830, 250);
        g2d.fillRect(0, 450, 830, 150);
        Rectangle p3 = new Rectangle(28, 250, 35, 2);
        g2d.fillRect(28, 250, 35, 2);
        Rectangle p4 = new Rectangle(330, 250, 35, 2);
        g2d.fillRect(330, 250, 35, 2);
        Rectangle p5 = new Rectangle(630, 250, 35, 2);
        g2d.fillRect(630, 250, 35, 2);

        try {
            sala_blocoB = ImageIO.read(
                    new File("src/Imagens/sala_blocoB.png"));
            sala2_blocoB = ImageIO.read(
                    new File("src/Imagens/sala2_blocoB.png"));
        } catch (IOException exc) {
        }
        g2d.drawImage(sala_blocoB, 0, 0, jj);
        g2d.drawImage(sala_blocoB, 300, 0, jj);
        g2d.drawImage(sala_blocoB, 600, 0, jj);
        g2d.drawImage(sala2_blocoB, 0, 400, jj);
        g2d.drawImage(sala2_blocoB, 300, 400, jj);
        g2d.drawImage(sala2_blocoB, 600, 400, jj);

        ArrayList<Rectangle> retangulos = new ArrayList<Rectangle>();
        retangulos.add(p1);
        retangulos.add(p2);
        retangulos.add(p3);
        retangulos.add(p4);
        retangulos.add(p5);
        return retangulos;
    }

    public ArrayList<Rectangle> desenha3AndarBlocoE() {
        try {
            imagebg = ImageIO.read(
                    new File("src/Imagens/bg_blocoE.jpg"));
        } catch (IOException e) {
        }
        int altura, largura;
        for (largura = 0; largura <= WIDTH; largura = largura + 20) {
            for (altura = 0; altura <= HEIGHT; altura = altura + 20) {
                g2d.drawImage(imagebg, largura, altura, jj);
            }
        }
        g2d.setColor(Color.red);
        g2d.drawString("E-3201", 25, 265);
        g2d.drawString("E-302", 330, 265);
        g2d.drawString("E-303", 630, 265);
        Rectangle p1 = new Rectangle(0, 0, 830, 250);
        g2d.fillRect(0, 0, 830, 150);
        Rectangle p2 = new Rectangle(0, 550, 830, 250);
        g2d.fillRect(0, 450, 830, 150);
        Rectangle p3 = new Rectangle(28, 250, 35, 2);
        g2d.fillRect(28, 250, 35, 2);
        Rectangle p4 = new Rectangle(330, 250, 35, 2);
        g2d.fillRect(330, 250, 35, 2);
        Rectangle p5 = new Rectangle(630, 250, 35, 2);
        g2d.fillRect(630, 250, 35, 2);

        try {
            sala_blocoB = ImageIO.read(
                    new File("src/Imagens/sala_blocoB.png"));
            sala2_blocoB = ImageIO.read(
                    new File("src/Imagens/sala2_blocoB.png"));
        } catch (IOException exc) {
        }
        g2d.drawImage(sala_blocoB, 0, 0, jj);
        g2d.drawImage(sala_blocoB, 300, 0, jj);
        g2d.drawImage(sala_blocoB, 600, 0, jj);
        g2d.drawImage(sala2_blocoB, 0, 400, jj);
        g2d.drawImage(sala2_blocoB, 300, 400, jj);
        g2d.drawImage(sala2_blocoB, 600, 400, jj);

        ArrayList<Rectangle> retangulos = new ArrayList<Rectangle>();
        retangulos.add(p1);
        retangulos.add(p2);
        retangulos.add(p3);
        retangulos.add(p4);
        retangulos.add(p5);
        return retangulos;
    }

    public ArrayList<Rectangle> desenhaBlocoE() {
//        if(Flag.flagmitica == false){
//        player.setPosY(540);
//        player.setPosX(20);
//        Flag.flagmitica = true;
//        }
//        if(Flag.andar1BlocoE){
//            if(Flag.chegouPrimeiroAndar){
//            
//            Flag.chegouPrimeiroAndar = false;
//            }
//            //Flag.andar1BlocoE = false;
////              player.setPosY(480);
////              player.setPosX(20);
////              PainelBatalha pb = new PainelBatalha(player, inimigo, this);
////              pb.setBounds(0, 0, 830, 600);
////              jj.setVisible(false);
////              ProjetoIntegrado.janelaPrincipal.add(pb);
////              pb.requestFocus();
////              pb.setVisible(true);
//          }
        try {
            imagebg = ImageIO.read(
                    new File("src/Imagens/bg_blocoE.jpg"));
        } catch (IOException e) {
        }
        int altura, largura;
        for (largura = 0; largura <= WIDTH; largura = largura + 20) {
            for (altura = 0; altura <= HEIGHT; altura = altura + 20) {
                g2d.drawImage(imagebg, largura, altura, jj);
            }
        }
        try {
            corrimao_esquerda = ImageIO.read(
                    new File("src/Imagens/corrimao_esquerda.png"));
            corrimao_direita = ImageIO.read(
                    new File("src/Imagens/corrimao_direita.png"));
            tia_limpeza = ImageIO.read(
                    new File("src/Imagens/tia_limpeza.png"));
        } catch (IOException exc) {
        }

        g2d.drawImage(tia_limpeza, xTia1, yTia1, jj);
        Rectangle tia_limpeza1 = new Rectangle(xTia1, yTia1, 23, 30);

        g2d.setColor(Color.YELLOW);
        g2d.drawString("<- SALAS 1º ANDAR", 5, 490);
        g2d.drawString("<- SALAS 2º ANDAR", 5, 290);
        g2d.drawString("<- SALAS 3º ANDAR", 5, 90);
        g2d.setColor(Color.RED);

        Rectangle p1 = new Rectangle(0, 500, 750, 20);
        //g2d.fillRect(0, 500,750, 20);
        g2d.drawImage(corrimao_direita, 0, 500, jj);
        Rectangle p2 = new Rectangle(80, 400, 750, 20);
        //g2d.fillRect(80, 400, 750, 20);
        g2d.drawImage(corrimao_esquerda, 80, 400, jj);
        Rectangle p3 = new Rectangle(0, 300, 750, 20);
        //g2d.fillRect(0, 300,750, 20);
        g2d.drawImage(corrimao_direita, 0, 300, jj);
        Rectangle p4 = new Rectangle(80, 200, 750, 20);
        // g2d.fillRect(80, 200, 750, 20);
        g2d.drawImage(corrimao_esquerda, 80, 200, jj);
        Rectangle p5 = new Rectangle(0, 100, 750, 20);
        //g2d.fillRect(0, 100,750, 20);
        g2d.drawImage(corrimao_direita, 0, 100, jj);
        g2d.setColor(Color.YELLOW);
        Rectangle entrada1 = new Rectangle(0, 400, 5, 80);
        g2d.fillRect(0, 400, 5, 100);
        Rectangle entrada2 = new Rectangle(0, 200, 5, 80);
        g2d.fillRect(0, 200, 5, 100);
        Rectangle entrada3 = new Rectangle(0, 0, 5, 80);
        g2d.fillRect(0, 0, 5, 100);

        if (praCima) {
            yTia1--;
        }
        if (praBaixo) {
            yTia1++;
        }
        if (tia_limpeza1.intersects(p1)) {
            praCima = true;
            praBaixo = false;
        }
        if (tia_limpeza1.intersects(p2)) {
            praCima = false;
            praBaixo = true;
        }

        Rectangle jogador = new Rectangle(player.getPosX(), player.getPosY(), player.w, player.h);

//       if(jogador.intersects(tia_limpeza1)){
//           player.hpAtual = player.hpAtual - 10;
//       }


        ArrayList<Rectangle> retangulos = new ArrayList<Rectangle>();
        retangulos.add(p1);
        retangulos.add(p2);
        retangulos.add(p3);
        retangulos.add(p4);
        retangulos.add(p5);
        retangulos.add(entrada1);
        retangulos.add(entrada2);
        retangulos.add(entrada3);
        retangulos.add(tia_limpeza1);

        return retangulos;
    }

    public ArrayList<Rectangle> desenhaBlocoB() {
//        if(Flag.flagmitica == false){
//        player.setPosY(540);
//        player.setPosX(20);
//        Flag.flagmitica = true;
//        }
        try {
            chao_blocoB = ImageIO.read(
                    new File("src/Imagens/chao_blocoB.png"));
        } catch (IOException e) {
        }
        int altura, largura;
        for (largura = 0; largura <= WIDTH; largura = largura + 100) {
            for (altura = 0; altura <= HEIGHT; altura = altura + 100) {
                g2d.drawImage(chao_blocoB, largura, altura, jj);
            }
        }
        try {
            sala_blocoB = ImageIO.read(
                    new File("src/Imagens/sala_blocoB.png"));
            sala2_blocoB = ImageIO.read(
                    new File("src/Imagens/sala2_blocoB.png"));
        } catch (IOException exc) {
        }

        g2d.setColor(Color.YELLOW);

        g2d.drawString("B-109", 29, 265);
        g2d.drawString("B-108", 242, 345);
        g2d.drawString("B-201", 570, 265);
        g2d.drawString("B-202", 760, 345);
        Rectangle p1 = new Rectangle(0, 0, 300, 250);


        Rectangle p2 = new Rectangle(0, 350, 300, 250);
        g2d.fillRect(0, 350, 300, 250);

        Rectangle p3 = new Rectangle(530, 0, 750, 250);
        g2d.fillRect(530, 0, 750, 250);

        Rectangle p4 = new Rectangle(530, 350, 750, 250);
        g2d.fillRect(530, 350, 750, 250);

        Rectangle p5 = new Rectangle(29, 250, 35, 2);
        Rectangle p6 = new Rectangle(242, 345, 35, 2);
        Rectangle p7 = new Rectangle(560, 250, 35, 2);
        Rectangle p8 = new Rectangle(765, 345, 35, 2);


        g2d.drawImage(sala_blocoB, 0, 0, jj);
        g2d.drawImage(sala_blocoB, 530, 0, jj);
        g2d.drawImage(sala2_blocoB, 0, 350, jj);
        g2d.drawImage(sala2_blocoB, 530, 350, jj);


        ArrayList<Rectangle> retangulos = new ArrayList<Rectangle>();
        retangulos.add(p1);
        retangulos.add(p2);
        retangulos.add(p3);
        retangulos.add(p4);
        retangulos.add(p5);
        retangulos.add(p6);
        retangulos.add(p7);
        retangulos.add(p8);


        return retangulos;
    }

    public void saveGame(Player player, String bloco) {
    }

    public void bolaDeFogoCima() {

        g2d.drawImage(bolaDeFogo, player.getPosX(), player.getPosY() - 30, jj);
        g2d.drawImage(bolaDeFogo, player.getPosX() - 30, player.getPosY() - 60, jj);
        g2d.drawImage(bolaDeFogo, player.getPosX(), player.getPosY() - 60, jj);
        g2d.drawImage(bolaDeFogo, player.getPosX() + 30, player.getPosY() - 60, jj);

    }

    public void bolaDeFogoBaixo() {

        g2d.drawImage(bolaDeFogo, player.getPosX(), player.getPosY() + 30, jj);
        g2d.drawImage(bolaDeFogo, player.getPosX() - 30, player.getPosY() + 60, jj);
        g2d.drawImage(bolaDeFogo, player.getPosX(), player.getPosY() + 60, jj);
        g2d.drawImage(bolaDeFogo, player.getPosX() + 30, player.getPosY() + 60, jj);

    }

    public void bolaDeFogoRight() {

        g2d.drawImage(bolaDeFogo, player.getPosX() + 30, player.getPosY(), jj);
        g2d.drawImage(bolaDeFogo, player.getPosX() + 60, player.getPosY() - 30, jj);
        g2d.drawImage(bolaDeFogo, player.getPosX() + 60, player.getPosY(), jj);
        g2d.drawImage(bolaDeFogo, player.getPosX() + 60, player.getPosY() + 30, jj);

    }

    public void bolaDeFogoLeft() {

        g2d.drawImage(bolaDeFogo, player.getPosX() - 30, player.getPosY(), jj);
        g2d.drawImage(bolaDeFogo, player.getPosX() - 60, player.getPosY() - 30, jj);
        g2d.drawImage(bolaDeFogo, player.getPosX() - 60, player.getPosY(), jj);
        g2d.drawImage(bolaDeFogo, player.getPosX() - 60, player.getPosY() + 30, jj);

    }
}
